<?php
/**
 * callback form accounting/admin
 */
function acctg_admin(){
	$s = "<h2>Accounting Administration</h2>";
	
	return $s;
}

/**
 * callback for accounting/admin/db
 */
function acctg_admin_db(){
	drupal_add_js(drupal_get_path("module","accounting")."/scripts/acctg_admin.js");
	$s = "$(function(){ $(\"#acctg-save\").click(function(){ acctg_admin.save_db_config(\"#acctg-db-name\"); }); });";
	drupal_add_js($s,"inline");
	
	$s = "<div id=\"acctg-admin-db\">";
	$s .= "\n\t<label>Database Name <input id=\"acctg-db-name\" type=\"text\" title=\"Accounting database name\"/></label>";
	$s .= "\n\t<button id=\"acctg-save\">Save</button>";
	$s .= "\n</div>";
	
	return $s;
}

/**
 * callback for accounting/admin/db/save
 */
function acctg_admin_db_save(){
	if(isset($_POST["db"])){
		return drupal_json(array("return_value"=>true));
	} else {
		return drupal_json(array("return_value"=>false,"error"=>"Missing argument: 'db'"));
	}
}